//引入mongoose模块
const mongoose = require('mongoose');

//引入config.js文件，并获取MongoDB的URL地址
const config = require('./index.js')

// 连接MongoDB数据库
mongoose.connect(config.URL);

// 监听数据库连接状态
mongoose.connection.on('error', err => {
     console.log(err);
});

mongoose.connection.on('disconnected', () => {
      console.log('***********断开连接***********')
});
mongoose.connection.on('open', () => {
      console.log('***********连接成功***********')
});